package com.pesilo.mvc.view
{
	import com.pesilo.mvc.controller.ApplicationFacade;
	import com.pesilo.mvc.view.component.mediator.BackgroundContainerMediator;
	import com.pesilo.mvc.view.component.mediator.NavigationContainerMediator;
	import com.pesilo.mvc.view.component.mediator.ShowContainerMediator;
	import com.pesilo.mvc.view.component.module.BackgroundContainerComponent;
	import com.pesilo.mvc.view.component.module.NavigationContainerComponent;
	import com.pesilo.mvc.view.component.module.ShowContainerComponent;
	import com.pesilo.norms.Norms;
	
	import org.puremvc.as3.multicore.interfaces.IMediator;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;

	public class ApplicationMediator extends Mediator implements IMediator
	{
		public static const NAME:String="ApplicationMediator";
		public function ApplicationMediator(viewComponent:Object)
		{
			super(NAME,viewComponent);
		}
		
		override public function onRegister():void{
			facade.registerMediator(new BackgroundContainerMediator(view.bgContainer));
			facade.registerMediator(new ShowContainerMediator(view.showContainer));
			facade.registerMediator(new NavigationContainerMediator(view.navigationContainer));
		}
		
		override public function listNotificationInterests():Array{
			return[
				ApplicationFacade.SHOW_EVENT
			];
		}
		
		override public function handleNotification(notification:INotification):void{
			var data:Object=notification.getBody();
			
			switch(notification.getName()){
				case ApplicationFacade.SHOW_EVENT:
					facade.sendNotification(ApplicationFacade.SHOW_HOMEPAGE_EVENT);
					facade.sendNotification(ApplicationFacade.SHOW_NAVIGATION_EVENT);
					
					break;
			}
		}
		
		protected function get view():Pesilo{
			return viewComponent as Pesilo;
		}
	}
}